
import config from "./config"

function get(url="",data={},token){
return new Promise((resolve,reject)=>{
  wx.request({
    url:config.baseUrl+url,
    data:data,
    method:"get",
    header:{
      'content-type': 'application/json', // 默认值,   post 用这个application/x-www-form-urlencoded     get application/json   yes
      Authorization:token
    },
    success:res=>{
      resolve(res)
    },
    fail:err=>{
      reject(err)
    }
  })
})
}


function post(url="",data={},token){
  return new Promise((resolve,reject)=>{
    wx.request({
      url:config.baseUrl+url,
      data:data,
      method:"post",
      header:{
        'content-type': 'application/x-www-form-urlencoded', // 默认值,   post 用这个application/x-www-form-urlencoded     get application/json   yes
        Authorization:token
      },
      success:res=>{
        resolve(res)
      },
      fail:err=>{
        reject(err)
      }
    })
  })
  }


export {get,post}